{extend name="../../admin/view/main"}

{block name="button"}
<!--{if auth("bgadd")}-->
<button class='layui-btn layui-btn-sm layui-btn-primary' data-action='{:url("bgadd")}' data-rule="goods_id#{key};brand_id#{$brand_id}">添加商品</button>
<!--{/if}-->
{/block}

{block name="content"}
<div class="layui-tab layui-tab-card think-bg-white">
    <div class="layui-tab-content">
        <form action="admin.html#/data/shop.brand/brandgoods?from=1" autocomplete="off" class="layui-form layui-form-pane form-search" method="get" onsubmit="return false">

            <div class="layui-form-item layui-inline">
                <label class="layui-form-label">商品名称</label>
                <label class="layui-input-inline">
                    <input class="layui-input" name="name" placeholder="请输入编号或名称" value="{$get.name|default=''}">
                </label>
            </div>
            <div class="layui-form-item layui-inline">
                <label class="layui-form-label">销售状态</label>
                <label class="layui-input-inline">
                    <select class="layui-select" name="status">
                        <option value=''>-- 全部状态 --</option>
                        {foreach ['已下架的商品','销售中的商品'] as $k=>$v}
                        {if input('status','-') eq $k.''}
                        <option selected value="{$k}">{$v}</option>
                        {else}
                        <option value="{$k}">{$v}</option>
                        {/if}{/foreach}
                    </select>
                </label>
            </div>
            <div class="layui-form-item layui-inline">
                <input type="hidden" value="{$brand_id}" name="id">
                <button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
            </div>
        </form>

        <table class="layui-table margin-top-10" lay-skin="line">
            {notempty name='list'}
            <thead>
            <tr>
                <th class='list-table-check-td think-checkbox'>
                    <label><input data-auto-none data-check-target='.list-check-box' type='checkbox'></label>
                </th>

                <th class='list-table-sort-td'>
                    <button class="layui-btn layui-btn-xs" data-reload type="button">刷 新</button>
                </th>
                <th class='text-left nowrap'>商品信息</th>
                <th class='text-left nowrap'></th>
                <th class='text-left nowrap'>商品状态</th>
                <th></th>
            </tr>
            </thead>
            {/notempty}
            <tbody>
            {foreach $list as $key=>$vo}
            <tr>
                <td class='list-table-check-td think-checkbox'>
                    <label><input class="list-check-box" type='checkbox' value='{$vo.id}'></label>
                </td>
                <td class='list-table-sort-td'>
                    <label><input class="list-sort-input" data-action-blur="{:sysuri()}" data-loading="false" data-value="id#{$vo.id};action#sort;sort#{value}" value="{$vo.sort}"></label>
                </td>
                <td class='nowrap'>
                    {notempty name='vo.cover'}
                    <div class="headimg headimg-no" data-tips-hover data-tips-image data-lazy-src="{$vo.cover}"></div>
                    {/notempty}
                    <div class="inline-block sub-span-blue">
                        <div>商品名称：<span>{$vo.name|default='--'}</span></div>
                        <div>商品编号：<span>{$vo.code|default='--'}</span></div>
                    </div>
                </td>
                <td>
                    <div class="nowrap">
                        {notempty name='vo.cateinfo'}
                        {:join('<span class="layui-icon layui-icon-right font-s10 color-blue"></span>', $vo.cateinfo.names)}
                        {/notempty}
                    </div>
                </td>
                <td class='nowrap'>
                    累计库存 <b>{$vo.stock_total}</b> 件，剩余库存 <b>{$vo.stock_total-$vo.stock_sales}</b> 件 ( 已销售 <b>{$vo.stock_sales}</b> 件 )
                    <div class="notselect margin-top-5">
                        {eq name='vo.status' value='0'}<span class="layui-badge layui-bg-gray layui-border-red">已下架</span>{else}<span class="layui-badge layui-bg-gray layui-border-green">销售中</span>{/eq}

                       <span class="layui-badge layui-bg-gray layui-border-green">需要发货</span>

                    </div>
                </td>
                <td class='nowrap sub-strong-blue'>
                    <!--{if auth("bgremove")}-->
                    {if $vo.selected eq 0}
                    <a class="layui-btn layui-btn-xs layui-btn-active" data-action="{:url('bgadd')}" data-confirm="确定要加入该商品吗？" data-value="goods_id#{$vo.id};brand_id#{$brand_id}">加 入</a>
                    {else/}
                    <a class="layui-btn layui-btn-xs layui-btn-primary" >已 加 入</a>
                    {/if}
                    <!--{/if}-->
                </td>
            </tr>
            {/foreach}
            </tbody>
        </table>
        {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
    </div>
</div>
{/block}
